import { useFeedStore } from '@/store/feed'
import API from '@/http'

export function useSyncFeeds(request) {
  const FEED_REQUESTS = [
    // 主頁推薦
    API.Media.getForyouList,

    // 主頁追蹤
    API.Media.getFollowList,

    // 指定參數媒體
    API.Media.getPostList,
    API.Media.getVideoList,
    API.Media.getPhotoList,
    API.Media.getShopList,
    API.Media.getFavorite,

    // 搜索
    API.Search.video,
    API.Search.image,
    API.Search.favorite,
    API.Search.buy,
    API.Search.tagDetail,
  ]

  const feedStore = useFeedStore()
  const { syncFeeds } = feedStore

  return FEED_REQUESTS.includes(request) ? syncFeeds : (v) => v
}
